class ApplicationController < ActionController::Base
  #防止csrf
  protect_from_forgery with: :exception
  before_action :set_locale
  before_action :set_raven_context
  include CommonHelper

  #获取当前登录的用户
  before_action :current_admin

  def set_locale
    I18n.locale = params[:locale] || I18n.default_locale
  end

  def current_admin
    if !user_login_in?
      redirect_to(:action => 'new',:controller => 'common')
    else
      @current_user = current_user
    end
  end

    def set_raven_context
    Raven.user_context(id: session[:user_id]) # or anything else in session
    Raven.extra_context(params: params.to_h, url: request.url)
  end



end
